//! Tests.debug.js
//

(function() {

Type.registerNamespace('Tests.Pages');

////////////////////////////////////////////////////////////////////////////////
// Tests.Pages.BlankTest

Tests.Pages.BlankTest = function Tests_Pages_BlankTest() {
    /// <field name="suiteName" type="String" static="true">
    /// </field>
    /// <field name="instance" type="Tests.Pages.BlankTest" static="true">
    /// </field>
    Tests.Pages.BlankTest.initializeBase(this, [ 'BlankTest' ]);
    var test1 = new Test('BlankTest 1').addToSuite(this).actionDx(function(aw) {
    });
    new Test(TestSuite.allTestsName).addToSuite(this).goTo(ThemeYoshi.defaultPageName).call(test1);
}


////////////////////////////////////////////////////////////////////////////////
// Tests.Pages.CreateSpaceTests

Tests.Pages.CreateSpaceTests = function Tests_Pages_CreateSpaceTests() {
    /// <field name="suiteName" type="String" static="true">
    /// </field>
    /// <field name="instance" type="Tests.Pages.CreateSpaceTests" static="true">
    /// </field>
    Tests.Pages.CreateSpaceTests.initializeBase(this, [ 'CreateSpaceTests' ]);
    var spaceName = 'testspace72';
    var baseName = Uri.join('../spaces/', spaceName);
    TestSuite.setVar('@SpaceName', spaceName);
    TestSuite.setVar('@SpaceNameTitle', 'your space name');
    TestSuite.setVar('@EmailTitle', 'your email address');
    TestSuite.setVar('@PasswordTitle', 'password');
    TestSuite.setVar('@PasswordAgainTitle', 'password again');
    TestSuite.setVar('@AnswerTitle', 'answer');
    TestSuite.setVar('@SpaceNameFail', Site.spaceNameShortMsg);
    TestSuite.setVar('@SpaceNameLongFail', Site.spaceNameLongMsg);
    TestSuite.setVar('@SpaceNameCaseFail', Site.spaceNameLowerMsg);
    TestSuite.setVar('@SpaceNameLettersFail', Site.spaceNameLettersMsg);
    TestSuite.setVar('@EmailFail', Site.emailValidMsg);
    TestSuite.setVar('@PasswordFail', Site.passwordLengthMsg);
    TestSuite.setVar('@PasswordAgainFail', Site.passwordMatchMsg);
    TestSuite.setVar('@AnswerFail', Site.incorrectMathMsg);
    var testFieldFailure = new Test('').addToSuite(this).comment('Testing field [@{field}] - title=@{title}, value=@{value}, msg=@{fail}').waitFor('@field').enter('').waitFor(function(tt) {
        return tt.lastSelect.prev('input');
    }, '@title').waitFor('@field').focus().waitFor(function(tt) {
        return tt.lastSelect.prev('input');
    }, '@title').waitFor('@field').enter('@value').waitNot(function(tt) {
        return tt.lastSelect.prev('input');
    }, '@title').press('#CreateButton').waitFor(".Ask:contains('@{fail}')").press('.Ask .OkBtn');
    var testAllFields = new Test('. Test input fields').addToSuite(this).call(testFieldFailure, { '@field': '#SpaceName', '@title': '@SpaceNameTitle', '@value': 'abc', '@fail': '@SpaceNameFail' }).call(testFieldFailure, { '@field': '#SpaceName', '@title': '@SpaceNameTitle', '@value': 'abcabcabcabcabcabcabc', '@fail': '@SpaceNameLongFail' }).call(testFieldFailure, { '@field': '#SpaceName', '@title': '@SpaceNameTitle', '@value': 'Abcd', '@fail': '@SpaceNameCaseFail' }).call(testFieldFailure, { '@field': '#SpaceName', '@title': '@SpaceNameTitle', '@value': '#bcd', '@fail': '@SpaceNameLettersFail' }).waitFor('#SpaceName').enter('abcd').call(testFieldFailure, { '@field': '#Email', '@title': '@EmailTitle', '@value': 'a@.com', '@fail': '@EmailFail' }).waitFor('#Email').enter('a@b.com').call(testFieldFailure, { '@field': '#Password', '@title': '@PasswordTitle', '@value': '1234567', '@fail': '@PasswordFail' }).waitFor('#Password').enter('12345678').call(testFieldFailure, { '@field': '#PasswordAgain', '@title': '@PasswordAgainTitle', '@value': '12345679', '@fail': '@PasswordAgainFail' }).waitFor('#Password', Test.isEmpty).enter('12345678').waitFor('#PasswordAgain', Test.isEmpty).enter('12345678').call(testFieldFailure, { '@field': '#MathResult', '@title': '@AnswerTitle', '@value': '9999', '@fail': '@AnswerFail' }).waitFor('#MathResult', Test.isEmpty).enter('-9999');
    var createSpace = new Test('. Create New Space').addToSuite(this).comment('Creating space [@{SpaceName}]').actionDx(function() {
        Nsb.Storage.setLocal('DevNoEmail', true);
    }).waitFor('#SpaceName').enter('@SpaceName').waitFor('#Email').enter('nsbawden@gmail.com').waitFor('#Password').enter('aaaaaaaa').waitFor('#PasswordAgain').enter('aaaaaaaa').waitFor('#MathResult').enter('-9999').pushMaxWait(40000).press('#CreateButton').waitFor(".Ask h1:contains('Created new space')").popMaxWait().press('.Ask .OkBtn');
    var deleteSpace = new Test('. Delete Test Space').addToSuite(this).comment('Deleting space [@{SpaceName}]').goTo('sites').waitFor("#SpacesList a:contains('@{SpaceName}')").press('#DEL@{SpaceName}').press('.Ask .OkBtn').waitNot("#SpacesList a:contains('@{SpaceName}')").goTo('home');
    var createTestSpace = new Test('@ Create + pupup window').addToSuite(this).call(createSpace);
    createTestSpace.loadJson(null, Uri.join(baseName, 'data/activate.php?act=test'));
    createTestSpace.actionDx(function() {
        Nsb.Storage.removeLocal(spaceName + '/' + Uri.end(ThemeYoshi.get_curatingKey()));
    }).actionDx(function() {
        Nsb.Storage.removeLocal(spaceName + '/' + Uri.end(ThemeYoshi.get_curatePasswordKey()));
    }).actionDx(function() {
        var w = window.open(Uri.join('../spaces/', spaceName, ThemeYoshi.masterPage), 'TestWindow');
        window.setTimeout(function() {
            w.opener.focus();
        }, 500);
    });
    new Test(TestSuite.allTestsName).addToSuite(this).call(testAllFields).call(createSpace).call(deleteSpace);
}


Type.registerNamespace('MetaTests.Pages');

////////////////////////////////////////////////////////////////////////////////
// MetaTests.Pages.MasterPageTests

MetaTests.Pages.MasterPageTests = function MetaTests_Pages_MasterPageTests() {
    /// <field name="suiteName" type="String" static="true">
    /// </field>
    /// <field name="instance" type="MetaTests.Pages.MasterPageTests" static="true">
    /// </field>
    MetaTests.Pages.MasterPageTests.initializeBase(this, [ MetaTests.Pages.MasterPageTests.suiteName ]);
    var savedUser = '@SavedUser';
    var savedPage = '@SavedPage';
    new Test(TestSuite.allTestsName).addToSuite(this).set(savedPage, function() {
        return ThemeYoshi.currentPageName;
    }).runPageSuite(ThemeYoshi.defaultPageName).goTo(savedPage);
}


Tests.Pages.BlankTest.registerClass('Tests.Pages.BlankTest', TestSuite);
Tests.Pages.CreateSpaceTests.registerClass('Tests.Pages.CreateSpaceTests', TestSuite);
MetaTests.Pages.MasterPageTests.registerClass('MetaTests.Pages.MasterPageTests', TestSuite);
Tests.Pages.BlankTest.suiteName = 'BlankTest';
Tests.Pages.BlankTest.instance = new Tests.Pages.BlankTest();
Tests.Pages.CreateSpaceTests.suiteName = 'CreateSpaceTests';
Tests.Pages.CreateSpaceTests.instance = new Tests.Pages.CreateSpaceTests();
MetaTests.Pages.MasterPageTests.suiteName = 'All Tests';
MetaTests.Pages.MasterPageTests.instance = new MetaTests.Pages.MasterPageTests();
})();

//! This script was generated using Script# v0.7.4.0
